//
//  OperatorTableViewCell.m
//  mosad_hw_fin
//
//  Created by student9 on 2020/12/24.
//  Copyright © 2020 student9. All rights reserved.
//

#import "OperatorTableViewCell.h"

@interface OperatorTableViewCell()
@property (nonatomic, strong) UIImageView *imView;
@property (nonatomic, strong) UILabel *titleLabel;
@end

@implementation OperatorTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];//创建UI
    }
    return self;
}

- (void)createUI {
    _imView = [UIImageView new];
    _imView.backgroundColor = [UIColor whiteColor];
    [self addSubview:_imView];
    
    _titleLabel = [UILabel new];
    _titleLabel.textColor = [UIColor blackColor];
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    _titleLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:_titleLabel];
}

#pragma mark - 创建布局
- (void) createLayout {
    [_imView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(40, 40));
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.imView.mas_right).offset(20);
        make.height.mas_equalTo(40);
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [self createLayout];
}

-(void)setModel:(operatorTableViewModel *)model {
    _imView.image = [[UIImage imageNamed:model.image_url] TransformtoSize:CGSizeMake(50, 50)];
    _titleLabel.text = model.title;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
